package com.moliku.insurance.common.constant;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * MQ业务枚举常量
 *
 * @author Mr.Liu
 * @since 2021/2/25
 */
@Getter
public enum BusinessEnum {
    /**
     * 投保
     */
    SUBMIT_POLICY("0", "投保"),
    /**
     * 退保
     */
    CANCEL_POLICY("1", "退保");
    /**
     * 业务编码
     */
    private final String code;
    /**
     * 业务
     */
    private final String name;

    BusinessEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 获取业务名称
     *
     * @param code 公司编码
     * @return 业务名称
     */
    public static String getName(String code) {
        String name = "未匹配到业务";
        if (StringUtils.isNotBlank(code)) {
            for (BusinessEnum businessEnum : BusinessEnum.values()) {
                if (businessEnum.code.equalsIgnoreCase(code)) {
                    return businessEnum.getName();
                }
            }
        }
        return name;
    }
}
